Telemetry

interface Telemetry

The v7 telemetry integration seam (upstream's Telemetry, the revamped TelemetryIntegration): implement it ONCE and the loop feeds it every lifecycle event of every invocation — agent start/finish, step start/finish, model-call start/finish, tool-call start/finish (including tool executions resumed after an approval pause), errors, and aborts. Upstream: "Instead of wiring up individual callbacks on every call, you implement a Telemetry once and register it globally or pass it via telemetry.integrations."

Event payloads reuse the lifecycle hook event types (OnStartEvent, OnStepFinishEvent, ...) — upstream: "The event types for each method are the same as the corresponding event callbacks." Each is paired with the invocation's TelemetryCall for correlation.

Contract:

  • Telemetry OBSERVES. It never alters loop behavior: a method throw is swallowed by the loop (CancellationException still propagates).

  • onToolCallStart/onToolCallFinish may fire CONCURRENTLY (a step's tool calls execute in parallel) — implementations must be thread-safe.

  • All methods default to no-ops; implement only what you record.

Properties

Link copied to clipboard
abstract val name: String

Functions

Link copied to clipboard
open suspend fun onAbort(call: TelemetryCall, event: OnAbortEvent)
Link copied to clipboard
open suspend fun onAgentFinish(call: TelemetryCall, event: OnFinishEvent)
Link copied to clipboard
open suspend fun onAgentStart(call: TelemetryCall, event: OnStartEvent)
Link copied to clipboard
open suspend fun onError(call: TelemetryCall, event: OnErrorEvent)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open suspend fun onStepFinish(call: TelemetryCall, event: OnStepFinishEvent)
Link copied to clipboard
open suspend fun onStepStart(call: TelemetryCall, event: OnStepStartEvent)
Link copied to clipboard
open suspend fun onToolCallFinish(call: TelemetryCall, event: OnToolCallFinishEvent)

Exactly one of outputJson/errorMessage is non-null. NOT fired for a CANCELLED tool call — cancellation unwinds the loop, so integrations may see a start without a finish.

Link copied to clipboard
open suspend fun onToolCallStart(call: TelemetryCall, event: OnToolCallStartEvent)